package com.example.ecommercemarketing.helper;

import com.example.ecommercemarketing.entity.Merchant;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Random;

@Service
public class RecommendMerchantHelper {
    /**
     * 获取要优先推荐商品的商户列表（模拟了数据库查询和复杂的业务处理）
     *
     * @return 按优先级排序的商户列表
     */
    public List<Merchant> getRecommendMerchantList() {
        Random random = new Random();
        List<Merchant> merchantList = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            Merchant merchant = new Merchant();
            merchant.setId("id" + i);
            merchant.setLevel("level" + random.nextInt(100000));
            merchant.setPoints(random.nextInt(1000000000));
            merchantList.add(merchant);
        }
        // 按等级排序（假设等级数字越大优先级越高）
        merchantList.sort(Comparator.comparing(Merchant::getLevel).reversed());
        return merchantList;
    }
}
